#include <stdio.h>
#include <String.h>
int main()
{
    FILE *p;
    int i = 0, j = 0;
    char str[1000], str1[1000], c;
    if ((p = fopen("e:\\test.txt", "rt")) == NULL)
    {
        printf("无法打开");
        return 0;
    }
    else
    {
        while ((c = getc(p)) != EOF)
        {
            str[i] = c;
            i++;
        }
        fclose(p);
        str[i] = '\0';
        for (i = 0; i < strlen(str); i++)
        {
            if (str[i] == '/' && str[i + 1] == '/')
            {
                while (str[i++] != '\n')
                {
                }
                i--;
            } //单行注释
            else if (str[i] == '/' && str[i + 1] == '*')
            {
                while (!(str[i] == '*' && str[i + 1] == '/'))
                {
                    i++;
                }
                i += 1; //多行注释
            }
            else if (str[i] == ' ' && str[i + 1] == ' ')
            {
                while (str[i] == ' ')
                {
                    i++;
                }
                i--;
                if (str1[j - 1] != ' ')
                    str1[j++] = ' ';
            } //多个空格，去除空格

            //第二页
            else if (str[i] == '\n')
            {
                if (str1[j - 1] != ' ')
                    str1[j++] == ' ';
                //换行处理，
                else if (str[i] == 9)
                {
                    while (str[i] == 9)
                    {
                        i++;
                    }

                    if (str1[j - 1] != ' ')
                        str1[j++] = ' ';
                    i--;
                }
                else
                    str1[j++] = str[i]; //X他字符处理
            }
            str1[j] = '\0';
            if ((p = fopen("e:\\test1.txt ", "w")) == NULL)
            {
                printf("can not find it!");
                return 0;
            }
            else
            {
                if (fputs(str1, p) != 0)
                {
                    printf("存储失败！ ");
                }
                else
                    printf("存储成功！ ");
            }
            fclose(p);
        }
        return 0;
    }
    //第三页
}